<?php
/**
 * GPA Description
 * @package 
 * @name index
 * @filesource index.php
 * @author Meta Sanjaya
 */

include_once "config.php";

ob_start();

if(!isset($_GET['page'])) {
    $_GET['page'] = "";
}

switch($_GET['page']) {
    case "user":
    case "login":
        define("PAGE_URL", HTTP_SERVER . "app/User/");
        define("PAGE_PATH", dirname(__FILE__) . "/app/User/");

        if($_GET['page']=="login") {
            $page = "login.php";

            if(isset($_GET['act'])) {
                $page = $_GET['act'] . '.php';
            }
        } else {
            if(isset($_SESSION['user']) && $_GET['page']=="user") {
                $page = 'user.php';
            } else {
                $page = $_GET['act'] . '.php';
            }
        }
        
        include_once PAGE_PATH . $page;
    break;
    case "gallery":
    default:
        define("PAGE_URL", HTTP_SERVER . "app/ImageGallery/");
        define("PAGE_PATH", dirname(__FILE__) . "/app/ImageGallery/");

        if(isset($_GET['act'])) {
           $page = 'image-'.$_GET['act'].'.php';
        } else {
           $page = 'images.php';
        }

        include_once PAGE_PATH . $page;
    break;
}

ob_get_contents();

?>